package com.cat.Command;

import java.util.Map;

/**
 * @author cat
 * @version 2025/5/27 10:59
 * @description 具体命令类
 * @since JDK17
 */

public class OrderCommand implements Command {
    // 持有接收者对象
    private SeniorChef receiver;
    // 订单类
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "号桌的订单来了 : ");
        Map<String, Integer> foodDir = order.getFoodDir();
        // 厨师去做订单中的所有菜
        foodDir.entrySet().forEach(entry -> receiver.makeFood(entry.getKey(), entry.getValue()));
        System.out.println(order.getDiningTable() + "号桌的订单已经完成");
    }
}
